﻿using System.Collections.Generic;
using System.Security.Principal;

namespace Sidvall.Security
{
	public class CustomIdentity : IIdentity, Sidvall.Security.IClaimProvider
	{
		#region Public Members

		public string Name { get; set; }
		public bool IsAuthenticated { get; set; }
		#region AuthenticationType

		public string AuthenticationType
		{
			get
			{
				return "CustomIdentity";
			}
		}

		#endregion

		#region AddClaim

		public void AddClaim(Claim claim)
		{
			this.Claims.Add(claim);
		}

		#endregion
		#region AddClaims

		public void AddClaims(IEnumerable<Claim> claims)
		{
			this.Claims.AddRange(claims);
		}

		#endregion
		#region ClearClaims

		public void ClearClaims()
		{
			this.Claims.Clear();
		}

		#endregion
		#region FindClaim

		public Claim FindClaim(string claimType)
		{
			return this.Claims.FindClaim(claimType);
		}

		#endregion
		#region FindClaims

		public ClaimCollection FindClaims(string claimType)
		{
			return this.Claims.FindClaims(claimType);
		}

		#endregion
		#region HasClaim

		public bool HasClaim(string claimType, string value)
		{
			return this.Claims.HasClaim(claimType, value);
		}

		#endregion
		#region RemoveClaim

		public bool RemoveClaim(Claim claim)
		{
			return this.Claims.RemoveClaim(claim);
		}

		#endregion
		#region RemoveClaims

		public void RemoveClaims(IEnumerable<Claim> claims)
		{
			this.Claims.RemoveClaims(claims);
		}

		#endregion

		#endregion
		#region Private Members

		#region Claims

		private Sidvall.Security.ClaimCollection _Claims;
		private Sidvall.Security.ClaimCollection Claims
		{
			get
			{
				if (_Claims == null)
					_Claims = new Sidvall.Security.ClaimCollection();
				return _Claims;
			}
		}

		#endregion

		#endregion
		#region Constructors

		public CustomIdentity()
		{
		}

		#endregion
	}
}
